home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr11
/
pdox693.zip
/
TI1109.ASC
< prev
next >
Wrap
Text File
|
1992-08-17
|
6KB
|
199 lines
PRODUCT : Paradox NUMBER : 1109
VERSION : 4.0
OS : DOS
DATE : August 17, 1992 PAGE : 1/3
TITLE : Record Locks on a Network in Paradox 4.0
Intended Audience:
General network, PAL programmer
Prerequisites:
Basic understanding of table locks from Chapter 21 of Paradox 4.0
User's Guide. Use of multi-table forms from Chapter 16 of
Paradox 4.0's User's Guide. Use of CoEdit mode. A knowledge of
PAL is helpful.
Purpose:
Give a basic understanding of record locks to Paradox network
administrators and PAL programmers. Overall, this Tech Info
sheet is aimed more toward programmers.
First, a brief review of table locks:
FL - Full lock, prevents other users from accessing the
table.
WL - Write lock, prevents other users from modifying the
table.
PWL - Prevent write lock, guarantees that you can modify
the table.
PFL - Prevent full lock, guarantees that you can view and
read from the table.
In Paradox 4.0, there are three kinds of record locks: record
lock, write record lock, and group lock.
1) Interactively, you get a record lock by modifying an existing
record or by using <ALT-L>. In PAL, you usually get this through
LOCKRECORD (you can also use POSTRECORD [...] LEAVELOCKED, which
handles key violations better). You get exclusive modify access
to the record, equivalent to both a PWL and WL on a table, but
other users can view and read it. However, you do not get a
group lock from the record lock.
PRODUCT : Paradox NUMBER : 1109
VERSION : 4.0
OS : DOS
DATE : August 17, 1992 PAGE : 2/3
TITLE : Record Locks on a Network in Paradox 4.0
2) You get a write record lock on the master record whenever you
lock one of the details in a 1-1 or 1-M form. This is equivalent
to a WL on a table. Two users can both have write record locks,
but you can't get a record lock if someone else has a write
record lock and vice versa. From the viewpoint of other users, a
write record lock is the same as a record lock.
NOTE: In fact, you cannot tell the difference between a record
lock and a write record lock. If you do a RECORDSTATUS("Locked")
on the master with a write record lock, it will come back True,
but you won't be able to modify any of the fields (not just the
key(s)). To check for this condition, use the following code
(this assumes that you were able to previously lock a detail
record):
LOCKRECORD
IF RETVAL = False THEN
IF ERRORCODE() = 9 THEN ; check to see if record
; locked by someone else
; You still have the write record lock, and another user
; prevented you from getting the record lock
ELSE
; You now have a record lock
ENDIF
ELSE
; You shouldn't be here, as that would mean you didn't have
; a detail locked previously. You now have a record lock.
ENDIF
3) You get a group lock when you modify the key field(s) of a
master record. This gives you a pseudo-record lock on all
details that have a 1-1 or 1-M relationship. You must have a
record lock on the master to get a group lock, but having a
record lock does not necessarily guarantee that you can get a
group lock.
NOTE: There is no way to achieve a group lock other than by
attempting to modify the key field(s) of the master. Therefore,
you must use the following code to determine whether you can
obtain a group lock (it assumes you already have a record lock):
PRODUCT : Paradox NUMBER : 1109
VERSION : 4.0
OS : DOS
DATE : August 17, 1992 PAGE : 3/3
TITLE : Record Locks on a Network in Paradox 4.0
MOVETO [Key]
Key = [] ; Save the key value
CTRLBACKSPACE
IF ERRORCODE() = 65 THEN ; You get errorcode 65 when
MESSAGE "Can't lock master" ; you can't get a group lock
ELSE
[] = Key ; Restore the key value
ENDIF
.
. <insert your code here>
.
To remove any of the three types of locks, hit <ALT-L> in
interactive Paradox, or use UNLOCKRECORD in PAL.
Here are some common situations. To test them, set up a pair of
workstations right next to each other:
-- User1 has Detail in table view with record lock. User2 has
Master in formview with record lock. User2 tries to modify
Master's key. Gets an error message "Detail group locked by
User1". You can only get the group lock when you have the
capability to record lock *all* the details.
-- User1 is in Master form, with Detail record lock. User2 has a
second Detail record lock in the same form. Both users now have
a write RECORD LOCK on the master, and neither will be able to
modify it. You get the standard record lock message "Master has
been locked by UserX".
-- User1 is in multi-table form for Master1, User2 in Master2,
both forms with Detail in 1-M relationship. Either user can
record lock MasterX, either user can record lock any detail
record. If a Detail that User1 has locked also belongs to a
Master2 that User2 tries to modify the key field on, User2 will
get a group lock error.
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.